//
//  DatePickerView.swift
//  ptbuy
//
//  Created by MyMac on 2024/12/6.
//

import SwiftUI

// 日期选择器视图
struct DatePickerView: View {
    @Binding var screenTime: Date
    @Binding var isPresented: Bool
    @Binding var stringTime: String

    var body: some View {
        VStack {
            // 日期选择器
            DatePicker("", selection: $screenTime, displayedComponents: .date)
                .datePickerStyle(GraphicalDatePickerStyle())  // 选择器样式可以根据需求调整
                .padding()

            // 按钮来关闭弹框
            Button("确定") {
                let formatter = DateFormatter()
                formatter.dateFormat = "yyyy-MM-dd"
                stringTime = formatter.string(from: screenTime)
                isPresented = false  // 关闭弹框
            }
            .padding()
        }
    }
}
